<!-- components/agreement-popup.vue -->
<template>
  <view v-if="show" class="agreement-mask">
    <view class="agreement-box">
      <scroll-view scroll-y class="agreement-content">
        <text class="title">用户协议与隐私政策</text>
        <text class="text">
			<p>请你务必审慎阅谀、充分理解"用户协议"和"隐私政策"各条款，包括但不限于:为了更好的向你提供服务，我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。</p>
			<p> 你可阅读<text @tap="goUrl('/pages/my/agree?id=2')" style="color: blue;">《用户协议》</text>和<text @tap="goUrl('/pages/my/agree?id=1')" style="color: blue;">《隐私政策》</text>了解详细信息。如果你同意，请点击下面按钮开始接受我们的服务。</p>
		</text>
      </scroll-view>
      <view class="button-group">
        <button @click="handleReject" class="reject-btn">拒绝</button>
        <button @click="handleAgree" class="agree-btn">同意</button>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    show: {
      type: Boolean,
      default: false
    }
  },
  methods: {
	goUrl(url){
		if(!url){return} 
		uni.navigateTo({
			url:url
		})
	},
    handleAgree() {
		// uni.setStorageSync('hasAgreed',true)
		this.$emit('agree');
    },
    handleReject() {
		// #ifdef APP-PLUS
		plus.runtime.quit();
		return true //return true的意思是禁止返回到上一个界面
		// #endif
    }
  }
}
</script>

<style>
.agreement-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.agreement-box {
  width: 80%;
  background: #fff;
  border-radius: 12rpx;
  padding: 30rpx;
}
.agreement-content {
  max-height: 60vh;
  margin-bottom: 30rpx;
}
.title {
  font-size: 36rpx;
  font-weight: bold;
  display: block;
  align-items: center;
  margin-bottom: 20rpx;
  text-align: center;
}
.text {
  font-size: 28rpx;
  color: #666;
}
.button-group {
  display: flex;
  gap: 20rpx;
}
.agree-btn {
  flex: 1;
  background: #007AFF;
  color: white;
}
.reject-btn {
  flex: 1;
  background: #ddd;
  color: #666;
}
</style>